# Maintainer: Diego Sogari <diego.sogari@falker.com.br>

_realname=uriparser
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.8.4
pkgrel=2
pkgdesc="RFC 3986 URI parsing and processing libary (mingw-w64)"
arch=('any')
url="https://uriparser.sourceforge.io/"
license=('New BSD License')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "automake" "autoconf")
checkdepends=("${MINGW_PACKAGE_PREFIX}-cpptest")
source=("https://downloads.sourceforge.net/project/${_realname}/Sources/${pkgver}/${_realname}-${pkgver}.tar.bz2"
        "${_realname}-${pkgver}.patch")
sha256sums=('ce7ccda4136974889231e8426a785e7578e66a6283009cfd13f1b24a5e657b23'
            'f1f542c77e0f27a34ce990ea1c8bd2bba0094a6d553fca06ceb1a8db81f672fe')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "../${_realname}-${pkgver}.patch"
  autoreconf -fvi
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  
  ../${_realname}-${pkgver}/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --disable-doc

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
